<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import = "cong.Note" %>
<%@ page import = "cong.Dbconnection" %>
<%@ page import = "java.util.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<script type="text/javascript">
function checkTitle(){
	var title =document.getElementsById("title_id"); 
	if(title.value == ""){
		alert("tilte cannot be null");
		title.focus;
		return false;
	}else{
		add_note_form.submit();
	}	
}
</script>
<body>
<center>
	<h2>留言板</h2>
	<form name="add_note_form" action="ReceiveNoteServlet" method="post" onsubmit="checkTitle()">
	<table>
		<tr><td>标题</td>
			<td><input id="title_id" name="title" type="text" size="20"/></td></tr>
		<tr><td>内容</td>
			<td><textarea name="content" rows="8" cols="40"></textarea></td></tr>
		<tr><td>联系方式</td>
		    <td><input id="contact_id" name="contact" type="text" size="20"></td></tr>
	</table>
	<input type="submit" name=“button” value="提交"/>
	<input type="reset" value="重置"/>
	<table border="1">
		<tr>		
		
  		<th>标题</th>
  		<th>留言内容</th>
  		<th>联系方式</th>
		</tr>
		<%
			ArrayList arrayList = (ArrayList)session.getAttribute("arrayList");
		  			if( arrayList == null) arrayList = new Dbconnection().getNote() ; 
		  			//创建迭代器
		  			Iterator iter = arrayList.iterator();
		  			while(iter.hasNext()){
		  				Note note=(Note)iter.next();
		%>
  				<tr> 					
  					<td><%= note.getTitle() %></td>  					
  					<td><%= note.getContent() %></td>
  					<td><%= note.getContact()%></td>
  				</tr>
  		<% 
  			}
  		%>
	</table>
	
	</form>
</center>
</body>
</html>